package com.lune.job.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.lune.job.mapper.ProfessionMapper;
import com.lune.job.pojo.Profession;
import com.lune.job.pojo.ResPageBean;
import com.lune.job.pojo.RespBean;
import com.lune.job.service.IProfessionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author Caiyilin
 * @since 2022-03-06
 */
@Service
public class ProfessionServiceImpl extends ServiceImpl<ProfessionMapper, Profession> implements IProfessionService {


    @Autowired
    private ProfessionMapper professionMapper;

    /**
     * 根据id查询行业
     * @param id
     * @return
     */
    @Override
    public Profession detailById(Integer id) {

        return professionMapper.selectById(id);
    }

    /**
     * 分页查询
     * @param currentPage
     * @param size
     * @param profession
     * @return
     */
    @Override
    public ResPageBean queryPage(Integer currentPage, Integer size, Profession profession) {
        Page<Profession> page = new Page<>(currentPage, size);
        IPage<Profession> professionIPage = professionMapper.queryPage(page, profession);
        ResPageBean resPageBean = new ResPageBean(professionIPage.getTotal(), professionIPage.getPages(), professionIPage.getRecords());
        return resPageBean;
    }

    /**
     * 查询所有
     * @return
     */
    @Override
    public List<Profession> tree() {

        return professionMapper.queryAll();
    }

    @Override
    public List<Profession> queryAll() {
        return professionMapper.queryAll();
    }
}
